//
//  HLSettingLogoutConfirmViewController.m
//  YueYue
//
//  Created by hulu001 on 2023/5/19.
//

#import "HLSettingLogoutConfirmViewController.h"

#import "HLSettingLogoutVerifyViewController.h"

@interface HLSettingLogoutConfirmViewController ()

@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) QMUIButton *startButton;

@end

@implementation HLSettingLogoutConfirmViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HLBackgroundColor;
}

- (void)setupNavigationItems
{
    [super setupNavigationItems];
    self.title = @"注销账号";
}

- (void)initSubviews
{
    [super initSubviews];
    self.scrollView = [[UIScrollView alloc] init];
    [self.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    self.contentView = [[UIView alloc] init];
    [self.scrollView addSubview:_contentView];
    [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.scrollView);
        make.width.equalTo(self.scrollView);
    }];
    
    self.titleLabel = [[UILabel alloc] init];
    _titleLabel.textColor = UIColorBlack;
    _titleLabel.font = UIFontMake(20);
    _titleLabel.text = @"注销账号存在以下风险";
    [_contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(NavigationContentTopConstant + 24);
    }];
    
    self.contentLabel = [[UILabel alloc] init];
    _contentLabel.textColor = HLTextColor2;
    _contentLabel.font = UIFontMake(15);
    _contentLabel.numberOfLines = 0;
    _contentLabel.qmui_lineHeight = 22;
    _contentLabel.text = @"账号注销后，30天后不可再次登录，账号进入永久封存状态.\n\n账户内未使用的金币和个人收益，在注销时视为放弃，注销后无法找回.";
    [_contentView addSubview:_contentLabel];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.equalTo(_titleLabel.mas_bottom).offset(24);
    }];

    
    self.startButton = [[QMUIButton alloc] init];
    [_startButton setTitle:@"同意并注销" forState:UIControlStateNormal];
    [_startButton setTitleColor:UIColorWhite forState:UIControlStateNormal];
    [_startButton.titleLabel setFont:UIFontMake(15)];
    [_startButton addTarget:self action:@selector(saveAction) forControlEvents:UIControlEventTouchUpInside];
    _startButton.cornerRadius = 12;
    [_startButton setBackgroundColor:HLMainColor];
    [self.view addSubview:_startButton];
    [_startButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_contentLabel);
        make.height.mas_equalTo(52);
        make.bottom.mas_equalTo(-(SafeAreaInsetsConstantForDeviceWithNotch.bottom + 40));
    }];

    [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_contentLabel.mas_bottom).offset(44);
    }];

    
}

- (void)saveAction
{
//    if (HLRunTime.shareInstance.mine.mobileNo.length > 1){
//        HLSettingLogoutVerifyViewController *logoutVerifyVC = [[HLSettingLogoutVerifyViewController alloc] init];
//        [self.navigationController pushViewController:logoutVerifyVC animated:YES];
//    } else {
//        
//    }
    
    [HLHelper logout];
    [HLUIHelper setRootLogin];
    
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleDarkContent;
}

- (UIImage *)qmui_navigationBarBackgroundImage
{
    return [UIImage qmui_imageWithColor:HLBackgroundColor];
}

- (nullable UIColor *)qmui_navigationBarTintColor
{
    return UIColorBlack;
}
@end
